<template>
  <div class="table-con">
    <el-table
      :data="tableData"
      border
      style="width: 100%; height: 5rem; overflow-y: auto"
      header-cell-class-name="custom-header"
      height="250"
    >
      <el-table-column type="index" label="序号" width="100"> </el-table-column>
      <el-table-column prop="jobName" label="任务名称" min-width="180">
      </el-table-column>
      <el-table-column prop="duration" label="持续时间" min-width="150">
      </el-table-column>
      <el-table-column prop="startTime" label="开始时间" min-width="150">
        <template slot-scope="scope">
          {{ formatDate(scope.row.startTime) }}
        </template>
      </el-table-column>
      <el-table-column prop="endTime" label="结束时间" min-width="150">
        <template slot-scope="scope">
          {{ formatDate(scope.row.startTime) }}
        </template>
      </el-table-column>
      <el-table-column prop="content" label="执行情况" min-width="150">
      </el-table-column>
      <el-table-column prop="entityType" label="实体类型" min-width="180">
      </el-table-column>
      <el-table-column
        prop="codeNumber"
        label="总编码数"
        min-width="180"
      ></el-table-column>
      <el-table-column
        prop="oldCodeNumber"
        label="原编码利用数"
        min-width="180"
      ></el-table-column>
      <!-- <el-table-column prop="status" label="状态" width="150">
      </el-table-column> -->
    </el-table>
    <div class="pg-con">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="historyquery.pageNumber"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="historyquery.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="historyquery.total"
      >
      </el-pagination>
    </div>
  </div>
</template>
  
<script>
import { getSysJobLogs } from "@/api/tasklist.js";
import moment from "moment";
export default {
  props: ["chosedTask","show"],
  components: {},
  computed: {},
  data: () => {
    return {
      historyquery: {
        jobName: "",
        pageNumber: 1,
        pageSize: 10,
        total: 10,
      },
      tableData: [
        {
          no: 1,
        },
        {
          no: 2,
        },
        {
          no: 3,
        },
      ],
    };
  },
  mounted() {
    this.getHistoryList();
  },
  watch: {
    show: function (newVal) {
      if (newVal) {
        this.getHistoryList();
      }
    },
  },
  methods: {
    formatDate(date) {
      return moment(date).format("YYYY-MM-DD HH:mm");
    },

    getHistoryList() {
      this.historyquery.jobName = this.chosedTask.jobName;
      this.historyquery.jobGroup = this.chosedTask.jobGroup;
      getSysJobLogs(this.historyquery)
        .then((res) => {
          this.tableData = res.records;
          this.historyquery.total = res.total;
        })
        .catch((err) => {});
    },
    handleSizeChange(val) {
      this.tasklistquery.pageSize = val;
      this.getHistoryList();
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.tasklistquery.pageNumber = val;
      this.getHistoryList();
      console.log(`当前页: ${val}`);
    },
  },
};
</script>
<style>
.custom-header {
  background: #f2f5f7 !important;
  font-family: SourceHanSansCN;
  font-weight: 500;
  font-size: 0.18rem;
  color: #333333;
}
</style>
  <style lang="less" scoped>
.table-con {
  width: 100%;
  overflow-y: hidden !important;
  height: fit-content;
}
.pg-con {
  text-align: right;
  padding-top: 0.2rem;
  :deep(.el-pagination.is-background .el-pager li:not(.disabled).active) {
    background-color: #3364fe;
  }
}
</style>
  